# -*- coding: utf8 -*-

import os
import sys
import datetime

from google.appengine.ext import db

# 用户
class User(db.Model):
    # 员工编码
    code = db.StringProperty(required=True)
    
    # 员工姓名
    name = db.StringProperty(required=True)
    
    def __str__(self):
        return u'User(%s, %s)' % (self.code, self.name)

# 店铺
class Shop(db.Model):
    # 店铺名
    name = db.StringProperty(required=True)
    # 电话
    telephone = db.StringProperty(required=True)
  
    def __str__(self):
        return u'Shop(%s, %s)' % (self.name, self.telephone)

# 菜单
class Dish(db.Model):
    #分组
    shop = db.ReferenceProperty(reference_class = Shop, collection_name='dishes')
    #菜名
    name = db.StringProperty(required=True)
    #价格
    price = db.FloatProperty(required=True)
  
    def __str__(self):
        return u'Dish(%s, %d)' % (self.name, self.price)
# 订单
class Order(db.Model):
    # 用户
    user = db.ReferenceProperty(reference_class = User, collection_name='orders')
    
    # 菜
    dish = db.ReferenceProperty(reference_class = Dish, collection_name='orders')

    # 量
    amount = db.IntegerProperty(required=True, default=1)
    
    # 日期
    date = db.DateProperty(auto_now_add=True)
    
    def __str__(self):
        return u'Order(%s, %s, %s)' % (self.user.name, self.dish.name, self.amount)

# 个人结余    
class Balance(db.Model):
    # 用户
    user = db.ReferenceProperty(reference_class = User, collection_name='balances')
    
    # 实付金额
    realPay = db.FloatProperty()
    
    # 结余金额
    balancePay = db.FloatProperty()
    
    # 日期
    date = db.DateProperty(auto_now_add=True)
    
#当日财务
class TodayChairMan(db.Model):
    # 用户
    user = db.ReferenceProperty(reference_class = User, collection_name='chairMans')
    
    # 收钱者
    isCharge = db.BooleanProperty()
    
    # 日期
    date = db.DateProperty(auto_now_add=True)    